<template>
  <div>
    
    <van-search
  
  show-action
  label="地址"
  placeholder="请输入搜索关键词"
  @search="onSearch"
  v-model="value"
>
  <template #action>
    <div  @click="onSearch">搜索</div>
  </template>
</van-search>
  <div class="xidBox" v-for="(x , i) in this.data" :key="i">
    <router-link to="/">{{x.jieshao}}</router-link>
  </div>
  </div>
</template>

<script>
import { Toast } from "vant";

export default {
  data() {
    return {
      data: [],
      value:'',
      
      
    }
  },
  mounted () {
    
      
  },
  methods: {
    
    onClickLeft() {
      Toast("返回");
    },
    onSearch() {
      this.data = []
      let id = this.$route.query.id;
      console.log("jjj", id);
      console.log(this);
      console.log("哈哈", id);
      this.axios.get(`http://localhost:3000/dis?id=${id}`).then((res) => {
        console.log('zzz',res);
        // this.data = res.data;
           if(this.value){
        
           let arr =res.data.filter(item =>{
            if(item.jieshao.includes(this.value)){
              // console.log('hhh',item)
              this.data.push(item) 
              console.log(this.data)
              
            }else{
              return false
            }
              
           })
          
            
          }
          this.value = ''
        
        
        // this.data.forEach(item=>{
          
        //   let duct = item
        //   console.log('ooo',duct)
        //   //  let ddd = item.jieshao
        //   //  console.log('lll',ddd)
         
          
        // //   if(this.value){
        // // console.log(this.value)
        // //    let arr =duct.filter((item) =>{item.xid == this.value})
        // //     console.log('nnn',arr)
        // //   }
        // })
      });
       
     
    },
  },
};
</script>

<style lang="scss" scoped>
.xidBox{
  width: 100vw;
  // height: 15vh;
  background: #eee;
  margin: 5px;
 >a{
  color: black;
  
 }
}
</style>